<?php include 'connectdb.php';?>
<table border='1' width="764">
    <tr>
        <td colspan='4'><strong>Preview</strong></td>
    </tr>
    <?php
        $q = "select * from home_stay where is_preview !=''";
        $result = mysqli_query($link, $q);
        if (mysqli_num_rows($result)==0){
    ?>
    <tr>
        <td align='center' colspan='4'>Not Found.</td>
    </tr>
    <?php
        }
        else{
    ?>
    <tr>
        <td width='150' align="center">Name</td>
        <td width='232' align="center">Location</td>
        <td width='232' align="center">Detail</td>
        <td width='150' align="center">Show</td>
    </tr>
    <?php
            while ($row = mysqli_fetch_array($result)){
    ?>
    <tr height='200'>
        <td width='150' valign="top"><br/><?php echo $row['home_stay_name'];?><br/>
            <?php 
                if ($row['home_stay_picture']==""){
            ?> 
                <img src="images/no_image/no_image.jpeg" width="140" height="140"></td>
            <?php
                }
                else {
                    echo '<img src='.$row['home_stay_picture'].'></td>';
                }
            ?>
        <td width='232' valign="top"><br/><?php echo $row['home_stay_location'];?></td>
        <td width='232' valign="top"><br/><?php echo $row['home_stay_detail'];?></td>
        <td width='150' align='center'><a href="index.php?preview=true&id=<?php echo $row['home_stay_id'];?>">preview</a></td>
    </tr>
    <?php    
            }
        }
        mysqli_close($con);
    ?>
</table>